package bug
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	
	
	
	/**
	 * bitmap代理。
	 * @author 青竹
	 * 
	 */
	public class Image extends Bitmap
	{
		private var _width:Number
		private var _height:Number;
		private var _smoothing:Boolean=false;
		private var _scaleX:Number;
		private var _scaleY:Number;
		public function Image(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false)
		{
//			if(bitmapData==null){
//			    bitmapData=new Animation("UI_Loading_Effect",5,5,25,false,new UI_Loading_Effect()).bitmapData;
//			}
			super(bitmapData, pixelSnapping, smoothing);
			if(bitmapData){
				_width=width;
				_height=height;
				_smoothing=smoothing;
			}
			//showLoading()
		}
		
		public function showLoading():void{
			if(bitmapData==null){
			  // bitmapData =  LoadingIcon.animation.bitmapData;
			}
		}
		
		override public function get width():Number{
		   if(bitmapData==null){
		      return _width;
		   }
		   return super.width;
		}
		
		override public function get height():Number{
			if(bitmapData==null){
				return _height;
			}
			return super.height;
		}
		override public function set width(value:Number):void{
			   _width=value;
			   if(bitmapData)
			   super.width=value;
		}
		override public function set height(value:Number):void{
				_height=value;
				if(bitmapData)
				super.height=value;
		}
		override public function set smoothing(value:Boolean):void{
				_smoothing=value;
				if(bitmapData)
				super.smoothing=value;
		}
		override public function set scaleX(value:Number):void{
			_scaleX=value;
			if(bitmapData)
			super.scaleX=value;
		}
		override public function set scaleY(value:Number):void{
			_scaleY=value;
			if(bitmapData)
			super.scaleY=value;
		}
		override public function set bitmapData(value:BitmapData):void{
		    super.bitmapData=value;
			if(!isNaN(_width)){
			    super.width=_width;
			}
			if(!isNaN(_height)){
			   super.height=_height;
			}
			super.smoothing=_smoothing;
			if(!isNaN(_scaleX)){
			   super.scaleX=_scaleX;
			}
			if(!isNaN(_scaleY)){
			    super.scaleY=_scaleY;
			}
		}
	}
}